<?

class i18n_change_action extends action_controller
{
	public function execute()
	{
		$language = $_GET['language'];

		if ( !in_array($language, config::all()->i18n['languages']) )
			$language = config::all()->i18n['default'];

		session::set('language', $language);
		response::redirect( $_SERVER['HTTP_REFERER'] ? $_SERVER['HTTP_REFERER'] : '/' );
	}
}